import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSCodeList } from '../../codelist/ipscode-list';
import { PSMDAjaxControlContainerImpl2 } from '../psmdajax-control-container-impl2';
import { IPSDEList } from './ipsdelist';
import { IPSDEListDataItem } from './ipsdelist-data-item';
import { IPSDEListItem } from './ipsdelist-item';
import { IPSLayoutPanel } from '../panel/ipslayout-panel';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDEListImpl extends PSMDAjaxControlContainerImpl2 implements IPSDEList {
  get codeName(): string {
    return this.M.codeName;
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes | null = null;

  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    if (this.emptytextpslanguageres != null) return this.emptytextpslanguageres;
    const value = this.M.getEmptyTextPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.emptytextpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getEmptyTextPSLanguageRes') as IPSLanguageRes;
    return this.emptytextpslanguageres;
  }

  get emptyTextPSLanguageRes(): IPSLanguageRes | null {
    return this.getEmptyTextPSLanguageRes();
  }

  getEmptyTextPSLanguageResMust(): IPSLanguageRes {
    const value = this.getEmptyTextPSLanguageRes();
    if (value == null) {
      throw new Error('未指定无值内容语言资源');
    }
    return value;
  }

  get groupMode(): 'NONE' | 'AUTO' | 'CODELIST' {
    return this.M.groupMode;
  }

  protected grouppsappdefield: IPSAppDEField | null = null;

  getGroupPSAppDEField(): IPSAppDEField | null {
    if (this.grouppsappdefield != null) return this.grouppsappdefield;
    const value = this.M.getGroupPSAppDEField;
    if (value == null) {
      return null;
    }
    this.grouppsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getGroupPSAppDEField') as IPSAppDEField;
    return this.grouppsappdefield;
  }

  get groupPSAppDEField(): IPSAppDEField | null {
    return this.getGroupPSAppDEField();
  }

  getGroupPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getGroupPSAppDEField();
    if (value == null) {
      throw new Error('未指定分组应用实体属性');
    }
    return value;
  }

  protected grouppscodelist: IPSCodeList | null = null;

  getGroupPSCodeList(): IPSCodeList | null {
    if (this.grouppscodelist != null) return this.grouppscodelist;
    const value = this.M.getGroupPSCodeList;
    if (value == null) {
      return null;
    }
    this.grouppscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getGroupPSCodeList') as IPSCodeList;
    return this.grouppscodelist;
  }

  get groupPSCodeList(): IPSCodeList | null {
    return this.getGroupPSCodeList();
  }

  getGroupPSCodeListMust(): IPSCodeList {
    const value = this.getGroupPSCodeList();
    if (value == null) {
      throw new Error('未指定分组代码表');
    }
    return value;
  }

  protected itempslayoutpanel: IPSLayoutPanel | null = null;

  getItemPSLayoutPanel(): IPSLayoutPanel | null {
    if (this.itempslayoutpanel != null) return this.itempslayoutpanel;
    const value = this.M.getItemPSLayoutPanel;
    if (value == null) {
      return null;
    }
    this.itempslayoutpanel = this.getPSModel4('control.panel.IPSLayoutPanel', value, 'getItemPSLayoutPanel') as IPSLayoutPanel;
    return this.itempslayoutpanel;
  }

  get itemPSLayoutPanel(): IPSLayoutPanel | null {
    return this.getItemPSLayoutPanel();
  }

  getItemPSLayoutPanelMust(): IPSLayoutPanel {
    const value = this.getItemPSLayoutPanel();
    if (value == null) {
      throw new Error('未指定项布局面板');
    }
    return value;
  }

  get minorSortDir(): 'ASC' | 'DESC' {
    return this.M.minorSortDir;
  }

  protected minorsortpsappdefield: IPSAppDEField | null = null;

  getMinorSortPSAppDEField(): IPSAppDEField | null {
    if (this.minorsortpsappdefield != null) return this.minorsortpsappdefield;
    const value = this.M.getMinorSortPSAppDEField;
    if (value == null) {
      return null;
    }
    this.minorsortpsappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getMinorSortPSAppDEField') as IPSAppDEField;
    return this.minorsortpsappdefield;
  }

  get minorSortPSAppDEField(): IPSAppDEField | null {
    return this.getMinorSortPSAppDEField();
  }

  getMinorSortPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getMinorSortPSAppDEField();
    if (value == null) {
      throw new Error('未指定默认排序应用实体属性');
    }
    return value;
  }

  get mobListStyle(): 'ICONVIEW' | 'LISTVIEW' | 'SWIPERVIEW' | 'LISTVIEW2' | 'LISTVIEW3' | 'LISTVIEW4' | 'EXTVIEW1' | 'EXTVIEW2' | 'EXTVIEW3' | 'EXTVIEW4' | 'EXTVIEW5' {
    return this.M.mobListStyle;
  }

  protected psdelistdataitems: IPSDEListDataItem[] | null = null;

  getPSDEListDataItems(): IPSDEListDataItem[] | null {
    if (this.psdelistdataitems == null) {
      this.psdelistdataitems = this.fillChildListModel(this.M.getPSDEListDataItems, 'control.list.IPSDEListDataItem') as IPSDEListDataItem[];
    }
    return this.psdelistdataitems;
  }

  get psDEListDataItems(): IPSDEListDataItem[] | null {
    return this.getPSDEListDataItems();
  }

  findPSDEListDataItem(objKey: any): IPSDEListDataItem | null {
    return this.getPSModel5('control.list.IPSDEListDataItem', this.getPSDEListDataItems(), objKey) as IPSDEListDataItem;
  }

  protected psdelistitems: IPSDEListItem[] | null = null;

  getPSDEListItems(): IPSDEListItem[] | null {
    if (this.psdelistitems == null) {
      this.psdelistitems = this.fillChildListModel(this.M.getPSDEListItems, 'control.list.IPSDEListItem') as IPSDEListItem[];
    }
    return this.psdelistitems;
  }

  get psDEListItems(): IPSDEListItem[] | null {
    return this.getPSDEListItems();
  }

  findPSDEListItem(objKey: any): IPSDEListItem | null {
    return this.getPSModel5('control.list.IPSDEListItem', this.getPSDEListItems(), objKey) as IPSDEListItem;
  }

  get pagingSize(): number {
    return this.M.pagingSize;
  }

  get hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  getHasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get enableGroup(): boolean {
    return this.M.enableGroup;
  }

  get enableRowEdit(): boolean {
    return this.M.enableRowEdit;
  }

  get enableRowEditGroup(): boolean {
    return this.M.enableRowEditGroup;
  }

  get enableRowEditOrder(): boolean {
    return this.M.enableRowEditOrder;
  }

  get enableRowNew(): boolean {
    return this.M.enableRowNew;
  }

  get noSort(): boolean {
    return this.M.noSort;
  }

  get showHeader(): boolean {
    return this.M.showHeader;
  }

  get cls(): string {
    return 'PSDEListImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSMDControl2' || cls == 'control.list.IPSDEList') return true;
    return super.instanceof(cls);
  }
}
